import { BasePageDto } from '@/common/base/base.dto';
import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
import {
  IsEnum,
  IsInt,
  IsNotEmpty,
  IsOptional,
  IsString,
  Max, MaxLength,
  Min,
} from 'class-validator';
import { BooleanNumber } from "common/utils/data";

export class BrandAdminIndexDto extends BasePageDto {
  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  title?: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsEnum(BooleanNumber)
  status?: BooleanNumber;

  // 不标准，以后再改
  @IsOptional()
  @ApiPropertyOptional()
  @IsEnum(BooleanNumber)
  enableTitleSort?: BooleanNumber;
}

export class BrandAdminCreateDto {
  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  @MaxLength(500)
  title: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  @MaxLength(500)
  img?: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  @MaxLength(500)
  desc?: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsInt()
  @Max(999)
  @Min(1)
  sort: number;
}

export class BrandAdminUpdateDto extends PartialType(BrandAdminCreateDto){
  @IsOptional()
  @ApiPropertyOptional()
  @IsEnum(BooleanNumber)
  status?: BooleanNumber;
}
